///*
// * Copyright (C) 2009 The Android Open Source Project
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// *      http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//
//package com.tstudy.laoshibang.weike;
//
//import org.androidannotations.annotations.AfterViews;
//import org.androidannotations.annotations.Click;
//import org.androidannotations.annotations.EActivity;
//import org.androidannotations.annotations.ViewById;
//
//import com.tstudy.laoshibang.R;
//import com.tstudy.laoshibang.base.BaseApplication;
//import com.tstudy.laoshibang.base.CONSTANT;
//import com.tstudy.laoshibang.custom.SoundView;
//import com.tstudy.laoshibang.custom.SoundView.OnVolumeChangedListener;
//import com.tstudy.laoshibang.mode.Weike;
//import com.tstudy.laoshibang.utils.CommonUtil;
//import com.tstudy.laoshibang.utils.LogUtil;
//
//import android.app.Activity;
//import android.app.Dialog;
//import android.content.Context;
//import android.content.Intent;
//import android.content.pm.ActivityInfo;
//import android.media.AudioManager;
//import android.media.MediaPlayer;
//import android.media.MediaPlayer.OnBufferingUpdateListener;
//import android.media.MediaPlayer.OnCompletionListener;
//import android.media.MediaPlayer.OnPreparedListener;
//import android.media.MediaPlayer.OnVideoSizeChangedListener;
//import android.os.Bundle;
//import android.os.Handler;
//import android.os.Looper;
//import android.os.Message;
//import android.os.MessageQueue.IdleHandler;
//import android.text.TextUtils;
//import android.util.Log;
//import android.view.Display;
//import android.view.GestureDetector;
//import android.view.GestureDetector.SimpleOnGestureListener;
//import android.view.Gravity;
//import android.view.LayoutInflater;
//import android.view.MotionEvent;
//import android.view.SurfaceHolder;
//import android.view.SurfaceView;
//import android.view.View;
//import android.view.View.OnClickListener;
//import android.view.View.OnLongClickListener;
//import android.webkit.WebView;
//import android.widget.ImageButton;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.PopupWindow;
//import android.widget.RelativeLayout;
//import android.widget.SeekBar;
//import android.widget.SeekBar.OnSeekBarChangeListener;
//import android.widget.TextView;
//
//@EActivity
//public class MediaPlayerActivity extends Activity implements
//        OnBufferingUpdateListener, OnCompletionListener,
//        OnPreparedListener, OnVideoSizeChangedListener, SurfaceHolder.Callback {
//	
//	@ViewById(R.id.weike_detail_activity_progress)
//	RelativeLayout mProgressLayout;
//	
//	@ViewById(R.id.weike_detail_activity_video_view)
//	SurfaceView mVideoView;
//	
//	
//	@ViewById(R.id.weike_detail_activity_weike_title)
//	TextView mWeikeTitle;
//	
//	@ViewById(R.id.weike_detail_activity_view_count)
//	TextView mViewCount;
//	
//	@ViewById(R.id.weike_detail_activity_love_count)
//	TextView mLoveCount;
//	
//	@ViewById(R.id.weike_detail_activity_love_icon)
//	ImageView mLoveIcon;
//	
//	@ViewById(R.id.weike_detail_activity_content)
//	WebView mContent;
//	int mWeikeId;
//	Weike mWeike;
//	boolean mIsLoading;
//    
//    private int mVideoWidth;
//    private int mVideoHeight;
//    private MediaPlayer mMediaPlayer;
//    private boolean mIsPrepared;
//    private int mDuration;
//    private SurfaceHolder holder;
//    private String path;
//    private boolean mIsVideoSizeKnown = false;
//    private boolean mIsVideoReadyToBePlayed = false;
//    
//    private View controlView = null;
//	private PopupWindow controler = null;
//	int mControlerHeight = 210;
//	private TextView durationTextView = null;
//	private int mCurrentBufferPercentage;
//	private TextView playedTextView = null;
//	private SeekBar seekBar = null;  
//	private int mProgress;
//	private int mScale = 30*1000;
//	private int mPlayedTime;
//	private ImageButton fullScreen = null;
//	private ImageButton backward = null;
//	private ImageButton start = null;
//	private ImageButton forward = null;
//	private ImageButton sound = null;
//	private GestureDetector mGestureDetector = null;
//	private AudioManager mAudioManager = null;  
//	private LayoutInflater mInflater;
//	
//	private SoundView mSoundView = null;
//	private PopupWindow mSoundWindow = null;
//	
//	private View extralView = null;
////	private PopupWindow extralWindow = null;
//	
//	private static int screenWidth = 0;
//	private static int screenHeight = 0;
//	private static int controlHeight = 0;  
//
//	private int maxVolume = 0;
//	private int currentVolume = 0;  
//	private final static int TIME = 6868;  
//	private boolean isControllerShow = true;
//	private boolean isPaused = false;
//	private boolean isFullScreen = false;
//	private boolean isSilent = false;
//	private boolean isSoundShow = false;
//	private boolean isOnline = false; 
//	private boolean isChangedVideo = false;
//	private boolean mStartWhenPrepared;
//    private int   mSeekWhenPrepared;
//    
//    public static void show(Activity activity,int position,String url){
//    	Intent intent = new Intent(activity, MediaPlayerActivity_.class);
//    	intent.putExtra(CONSTANT.ARGS.POSITION, position);
//    	intent.putExtra(CONSTANT.ARGS.URL,url);
//    	activity.startActivity(intent);
//    }
//	
//    /**
//     * 
//     * Called when the activity is first created.
//     */
//    @Override
//    public void onCreate(Bundle icicle) {
//        super.onCreate(icicle);
//        setContentView(R.layout.weike_detail_activity);
//        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
//        mInflater = getLayoutInflater();
//    }
//    @AfterViews
//	public void initView(){
//    	initController();
//    	Looper.myQueue().addIdleHandler(new IdleHandler(){
//			@Override
//			public boolean queueIdle() {
//				if(controler != null && mVideoView.isShown()){
//					controler.showAtLocation(mVideoView,mVideoView.getMeasuredHeight(), 0, 0);
//					controler.update(0,screenHeight-mVideoView.getMeasuredHeight()-75,screenWidth, mControlerHeight);
//				}
//				return false;  
//			}
//        });
//    	initSoundView();
//    	mGestureDetector = new GestureDetector(new SimpleOnGestureListener(){
//			@Override
//			public boolean onDoubleTap(MotionEvent e) {
////				// TODO Auto-generated method stub
////				if(isFullScreen){
////					setVideoScale(SCREEN_DEFAULT);
////				}else{
////					setVideoScale(SCREEN_FULL);
////				}
////				isFullScreen = !isFullScreen;
////				Log.d(TAG, "onDoubleTap");
////				
////				if(isControllerShow){
////					showController();
////				}
//				//return super.onDoubleTap(e);
//				return true;
//			}
//
//			@Override
//			public boolean onSingleTapConfirmed(MotionEvent e) {
//				// TODO Auto-generated method stub
//				if(!isControllerShow){
//					showController();
//					hideControllerDelay();
//				}else {
//					cancelDelayHide();
//					hideController();
//				}
//				//return super.onSingleTapConfirmed(e);
//				return true;
//			}
//
//			@Override
//			public void onLongPress(MotionEvent e) {
//				// TODO Auto-generated method stub
////				if(isPaused){
////					mVideoView.start();
////					start.setImageResource(R.drawable.pause);
////					cancelDelayHide();
////					hideControllerDelay();
////				}else{
////					mVideoView.pause();
////					start.setImageResource(R.drawable.play);
////					cancelDelayHide();
////					showController();
////				}
////				isPaused = !isPaused;
//				//super.onLongPress(e);
//			}	
//        });
//        holder = mVideoView.getHolder();
//        holder.addCallback(this);
//        holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
//        if (getIntent() != null) {
//        	path = getIntent().getStringExtra(CONSTANT.ARGS.URL);
//        	mPlayedTime = getIntent().getIntExtra(CONSTANT.ARGS.POSITION, 0);
//		}
//	}
//    
//    public void initController(){
//    	 controlView = getLayoutInflater().inflate(R.layout.controler, null);
//         controler = new PopupWindow(controlView);
//         fullScreen = (ImageButton) controlView.findViewById(R.id.fullscreen);
//         backward = (ImageButton) controlView.findViewById(R.id.backward);
//         start = (ImageButton) controlView.findViewById(R.id.start);
//         forward = (ImageButton) controlView.findViewById(R.id.forward);
//         sound = (ImageButton) controlView.findViewById(R.id.sound);
//         durationTextView = (TextView) controlView.findViewById(R.id.duration);
//         playedTextView = (TextView) controlView.findViewById(R.id.has_played);
////         fullScreen.setOnClickListener(new OnClickListener(){
//// 			@Override
//// 			public void onClick(View arg0) {
//// 				if(isFullScreen){
//// 					setVideoScale(SCREEN_DEFAULT);
//// 				}else{
//// 					setVideoScale(SCREEN_FULL);
//// 				}
//// 				isFullScreen = !isFullScreen;
//// 				Log.d(TAG, "onDoubleTap");
//// 				
//// 				if(isControllerShow){
//// 					showController();
//// 				}
////// 				Intent intent = new Intent();
////// 				intent.setClass(VideoPlayerActivity.this, VideoChooseActivity.class);
////// 				VideoPlayerActivity.this.startActivityForResult(intent, 0);
////// 				cancelDelayHide();
//// 			}
//         	
////         });
//         forward.setOnClickListener(new OnClickListener(){
// 			@Override
// 			public void onClick(View v) {
// 				seekTo(Math.max(0,getCurrentPosition() - mScale));
// 			}
//         	
//         });
//         
//         start.setOnClickListener(new OnClickListener(){
// 			@Override
// 			public void onClick(View v) {
// 				cancelDelayHide();
// 				if(isPaused){
// 					start();
// 					start.setImageResource(R.drawable.pause);
// 					hideControllerDelay();
// 				}else{
// 					pause();
// 					start.setImageResource(R.drawable.play);
// 				}
// 				isPaused = !isPaused;
// 			}
//         	
//         });
//         
//         backward.setOnClickListener(new OnClickListener(){
// 			@Override
// 			public void onClick(View v) {
// 				seekTo(Math.min(mDuration,getCurrentPosition() + mScale));
// 			}
//         });
//         seekBar = (SeekBar) controlView.findViewById(R.id.seekbar);
//         seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener(){
// 				@Override
// 				public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) {
// 					if(fromUser){
// 						if(!isOnline){
// 							seekTo(progress);
// 						}
// 					}
// 				}
// 	
// 				@Override
// 				public void onStartTrackingTouch(SeekBar arg0) {
// 					mHandler.removeMessages(HIDE_CONTROLER);
// 				}
// 	
// 				@Override
// 				public void onStopTrackingTouch(SeekBar seekBar) {
// 					// TODO Auto-generated method stub
// 					mHandler.sendEmptyMessageDelayed(HIDE_CONTROLER, TIME);
// 				}
//         	});
//    }
//    
//    public void initSoundView(){
//    	mSoundView = new SoundView(this);
//        mSoundView.setOnVolumeChangeListener(new OnVolumeChangedListener(){
//
//			@Override
//			public void setYourVolume(int index) {
//				 
//				cancelDelayHide();
//				updateVolume(index);
//				hideControllerDelay();
//			}
//        });
//        mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
//        maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
//        currentVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
//        mSoundWindow = new PopupWindow(mSoundView);
//        sound.setOnClickListener(new OnClickListener(){
//     		@Override
//     		public void onClick(View v) {
//     			// TODO Auto-generated method stub
//     			cancelDelayHide();
//     			if(isSoundShow){
//     				mSoundWindow.dismiss();
//     			}else{
//     				if(mSoundWindow.isShowing()){
//     					mSoundWindow.update(15,0,SoundView.MY_WIDTH,SoundView.MY_HEIGHT);
//     				}else{
//     					mSoundWindow.showAtLocation(mVideoView, Gravity.RIGHT|Gravity.CENTER_VERTICAL, 15, 0);
//     					mSoundWindow.update(15,0,SoundView.MY_WIDTH,SoundView.MY_HEIGHT);
//     				}
//     			}
//     			isSoundShow = !isSoundShow;
//     			hideControllerDelay();
//     		}   
//            });
//             sound.setOnLongClickListener(new OnLongClickListener(){
//     			@Override
//     			public boolean onLongClick(View arg0) {
//     				// TODO Auto-generated method stub
//     				if(isSilent){
//     					sound.setImageResource(R.drawable.soundenable);
//     				}else{
//     					sound.setImageResource(R.drawable.sounddisable);
//     				}
//     				isSilent = !isSilent;
//     				updateVolume(currentVolume);
//     				cancelDelayHide();
//     				hideControllerDelay();
//     				return true;
//     			}
//             	
//             });
//    }
//    public void setView(){
//		if (mWeike != null) {
//			if (mWeike.videos != null) {
////				play(mVideoView, null, null, mWeike.videos.get(0).videoIdxName);
//			}
//			mWeikeTitle.setText(mWeike.title);
//			mLoveCount.setText(mWeike.praiseNum + "");
//			mLoveIcon.setSelected(mWeike.isPraise==1);
//			String viewCountStr = BaseApplication.getResString(R.string.weike_detail_view_count);
//			mViewCount.setText(String.format(viewCountStr, mWeike.accessNum));
//			mContent.loadData(mWeike.detail, "text/html; charset=UTF-8",null);
//		}
//		
//	}
//    
//    @Click({R.id.weike_detail_new_back,R.id.weike_detail_new_share,R.id.weike_detail_new_love_icon})
//	public void actionClick(View view){
//		switch (view.getId()) {
//		case R.id.weike_detail_new_back:
//			finish();
//			break;
//		case R.id.weike_detail_new_share:
////			showShareDialog();
//			share(mWeike);
//			break;
//		case R.id.weike_detail_new_love_icon:
//			mWeike.isPraise = mWeike.isPraise==1?0:1;
//			view.setSelected(mWeike.isPraise==1);
//			CommonUtil.loveAnimator(view);
//			mWeike.praiseNum = mWeike.isPraise==0?mWeike.praiseNum-1:mWeike.praiseNum +1;
//			mLoveCount.setText(mWeike.praiseNum+"");
//			if (BaseApplication.checkLogin()) {
////				loveAction(mWeike.coseId,CONSTANT.LOVE_TYPE_ACTIVE,mWeike.isPraise==0?CONSTANT.UNLOVE_ACTION:CONSTANT.LOVE_ACTION);
//			}
//		default:
//			break;
//		}
//	}
//	Dialog mShareDialog;
//	LinearLayout mDialogView;
//	public void share(Weike weike){
//		String mDefaultShareStr = BaseApplication.getResString(R.string.community_list_title);
//		String mShareImg = null;
//		if (weike.videos != null && weike.videos.size() > 0) {
//			mShareImg = weike.videos.get(0).imgIdxName;
//		}
//		if(mShareDialog == null){
//			mDialogView = (LinearLayout) mInflater.inflate(R.layout.share_pop, null);
////			mShareDialog = buildAlertDialog(mDialogView,CommonUtil.dip2px(20));
//		}
//		if (mShareDialog.isShowing()) {
//			return;
//		}
//		final String title = TextUtils.isEmpty(weike.title)?mDefaultShareStr:weike.title;
//		final String content = TextUtils.isEmpty(weike.summary)?mDefaultShareStr:weike.summary;
////		CommonUtil.showShareDialog(this, mDialogView,mShareDialog, mInflater, mShareImg, title, content,weike.shareUrl);
//	}
//
//    private void getScreenSize(){
//		Display display = getWindowManager().getDefaultDisplay();
//        screenHeight = display.getHeight();
//        screenWidth = display.getWidth();
//        controlHeight = screenHeight/4;
//	}
//    
//    @Override
//	public boolean onTouchEvent(MotionEvent event) {
//		boolean result = mGestureDetector.onTouchEvent(event);
//		
//		if(!result){
//			if(event.getAction()==MotionEvent.ACTION_UP){
//				
//				/*if(!isControllerShow){
//					showController();
//					hideControllerDelay();
//				}else {
//					cancelDelayHide();
//					hideController();
//				}*/
//			}
//			result = super.onTouchEvent(event);
//		}
//		
//		return result;
//	}
//    private final static int PROGRESS_CHANGED = 0;
//    private final static int HIDE_CONTROLER = 1;
//    
//    private void updateVolume(int index){
//    	if(mAudioManager!=null){
//    		if(isSilent){
//    			mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);
//    		}else{
//    			mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, index, 0);
//    		}
//    		currentVolume = index;
//    		sound.setAlpha(findAlphaFromSound());
//    	}
//    }
//    private int findAlphaFromSound(){
//    	if(mAudioManager!=null){
//    		//int currentVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
//    		int alpha = currentVolume * (0xCC-0x55) / maxVolume + 0x55;
//    		return alpha;
//    	}else{
//    		return 0xCC;
//    	}
//    }
//    Handler mHandler = new Handler(){
//		@Override
//		public void handleMessage(Message msg) {
//			switch(msg.what){
//				case PROGRESS_CHANGED:
//					int i = getCurrentPosition();
//					seekBar.setProgress(i);
//					if(isOnline){
//						int j = getBufferPercentage();
//						seekBar.setSecondaryProgress(j * seekBar.getMax() / 100);
//					}else{
//						seekBar.setSecondaryProgress(0);
//					}
//					i/=1000;
//					int minute = i/60;
//					int hour = minute/60;
//					int second = i%60;
//					minute %= 60;
//					playedTextView.setText(String.format("%02d:%02d:%02d", hour,minute,second));
//					
//					sendEmptyMessageDelayed(PROGRESS_CHANGED, 100);
//					break;
//				case HIDE_CONTROLER:
//					hideController();
//					break;
//			}
//			super.handleMessage(msg);
//		}	
//    };
//    
//    public int getBufferPercentage() {
//        if (mMediaPlayer != null) {
//            return mCurrentBufferPercentage;
//        }
//        return 0;
//    }
//    
//    public int getCurrentPosition() {
//        if (mMediaPlayer != null && mIsPrepared) {
//            return mMediaPlayer.getCurrentPosition();
//        }
//        return 0;
//    }
//    
//    private void hideController(){
//		if(controler.isShowing()){
//			controler.update(0,0,0, 0);
////			extralWindow.update(0,0,screenWidth,0);
//			isControllerShow = false;
//		}
//		if(mSoundWindow.isShowing()){
//			mSoundWindow.dismiss();
//			isSoundShow = false;
//		}
//	}
//	
//	private void hideControllerDelay(){
//		mHandler.sendEmptyMessageDelayed(HIDE_CONTROLER, TIME);
//	}
//	
//	private void showController(){
//		controler.update(0,screenHeight-mVideoView.getMeasuredHeight()-75,screenWidth,mControlerHeight);
//		isControllerShow = true;
//	}
//	
//	private void cancelDelayHide(){
//		mHandler.removeMessages(HIDE_CONTROLER);
//	}
//
//    private void playVideo() {
//        doCleanUp();
//        try {
//            LogUtil.d("------path==" + path);
//            mCurrentBufferPercentage = 0;
//            mMediaPlayer = new MediaPlayer();
//            mMediaPlayer.setDataSource(path);
//            mMediaPlayer.setDisplay(holder);
//            mMediaPlayer.prepare();
//            mMediaPlayer.setOnBufferingUpdateListener(this);
//            mMediaPlayer.setOnCompletionListener(this);
//            mMediaPlayer.setOnPreparedListener(this);
//            mMediaPlayer.setOnVideoSizeChangedListener(this);
//            mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
//            seekTo(mPlayedTime);
//        } catch (Exception e) {
//            LogUtil.d("error: " + e.getMessage(), e);
//        }
//    }
//
//    public void onBufferingUpdate(MediaPlayer arg0, int percent) {
//        LogUtil.d("onBufferingUpdate percent:" + percent);
//        mCurrentBufferPercentage = percent;
//    }
//
//    public void onCompletion(MediaPlayer arg0) {
//        LogUtil.d("onCompletion called");
//    }
//
//    public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
//        LogUtil.d("onVideoSizeChanged called");
//        if (width == 0 || height == 0) {
//            LogUtil.d("invalid video width(" + width + ") or height(" + height + ")");
//            return;
//        }
//        mIsVideoSizeKnown = true;
//        mVideoWidth = width;
//        mVideoHeight = height;
//        if (mIsVideoReadyToBePlayed && mIsVideoSizeKnown) {
//            startVideoPlayback();
//        }
//    }
//
//    public void onPrepared(MediaPlayer mediaplayer) {
//        LogUtil.d("onPrepared called");
//        mIsVideoReadyToBePlayed = true;
//        mIsPrepared = true;
//        isFullScreen = false; 
//		if(isControllerShow){
//			showController();  
//		}
//		int i = getDuration();
//		Log.d("onCompletion", ""+i);
//		seekBar.setMax(i);
//		i/=1000;
//		int minute = i/60;
//		int hour = minute/60;
//		int second = i%60;
//		minute %= 60;
//		durationTextView.setText(String.format("%02d:%02d:%02d", hour,minute,second));
//		/*controler.showAtLocation(vv, Gravity.BOTTOM, 0, 0);
//		controler.update(screenWidth, controlHeight);
//		myHandler.sendEmptyMessageDelayed(HIDE_CONTROLER, TIME);*/
//		start();  
//		start.setImageResource(R.drawable.pause);
//		hideControllerDelay();
//		mHandler.sendEmptyMessage(PROGRESS_CHANGED);
//        
//        
//        if (mIsVideoReadyToBePlayed && mIsVideoSizeKnown) {
//            startVideoPlayback();
//        }
//    }
//    
//    public int getDuration() {
//        if (mMediaPlayer != null && mIsPrepared) {
//            if (mDuration > 0) {
//                return mDuration;
//            }
//            mDuration = mMediaPlayer.getDuration();
//            return mDuration;
//        }
//        mDuration = -1;
//        return mDuration;
//    }
//    
//    public void start() {
//        if (mMediaPlayer != null && mIsPrepared) {
//                mMediaPlayer.start();
//                mStartWhenPrepared = false;
//        } else {
//            mStartWhenPrepared = true;
//        }
//    }
//
//    public void pause() {
//        if (mMediaPlayer != null && mIsPrepared) {
//            if (mMediaPlayer.isPlaying()) {
//                mMediaPlayer.pause();
//            }
//        }
//        mStartWhenPrepared = false;
//    }
//    
//    public void seekTo(int msec) {
//        if (mMediaPlayer != null && mIsPrepared) {
//            mMediaPlayer.seekTo(msec);
//        } else {
//            mSeekWhenPrepared = msec;
//        }
//    }
//
//    public boolean isPlaying() {
//        if (mMediaPlayer != null && mIsPrepared) {
//            return mMediaPlayer.isPlaying();
//        }
//        return false;
//    }
//    public void stopPlayback() {
//        if (mMediaPlayer != null) {
//            mMediaPlayer.stop();
//            mMediaPlayer.release();
//            mMediaPlayer = null;
//        }
//    }
//
//
//    public void surfaceChanged(SurfaceHolder surfaceholder, int i, int j, int k) {
//        LogUtil.d("surfaceChanged called");
//
//    }
//
//    public void surfaceDestroyed(SurfaceHolder surfaceholder) {
//        LogUtil.d("surfaceDestroyed called");
//    }
//
//    public void surfaceCreated(SurfaceHolder holder) {
//        LogUtil.d("surfaceCreated called");
//        playVideo();
//
//    }
//
//    @Override
//	protected void onPause() {
//		mPlayedTime = getCurrentPosition();
//		pause();
//		start.setImageResource(R.drawable.play);
//		super.onPause();   
//	}
//
//	@Override
//	protected void onResume() {
//		if(!isChangedVideo){
//			seekTo(mPlayedTime);
//			start();  
//		}else{
//			isChangedVideo = false;
//		}
//		if(isPlaying()){
//			start.setImageResource(R.drawable.pause);
//			hideControllerDelay();
//		}
//		Log.d("REQUEST", "NEW AD !");
//		if(getRequestedOrientation()!=ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE){
//			setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
//		}
//		
//		super.onResume();
//	}
//
//    @Override
//    protected void onDestroy() {
//    	super.onDestroy();
//    	if(controler.isShowing()){
//			controler.dismiss();
//		}
//		if(mSoundWindow.isShowing()){
//			mSoundWindow.dismiss();
//		}
//		mHandler.removeMessages(PROGRESS_CHANGED);
//		mHandler.removeMessages(HIDE_CONTROLER);
//		if(isPlaying()){
//			stopPlayback();
//		}
//    }
//    private void doCleanUp() {
//        mVideoWidth = 0;
//        mVideoHeight = 0;
//        mIsPrepared = false;
//        mIsVideoReadyToBePlayed = false;
//        mIsVideoSizeKnown = false;
//    }
//
//    private void startVideoPlayback() {
//        holder.setFixedSize(mVideoWidth, mVideoHeight);
//        mMediaPlayer.start();
//    }
//    
//}
